<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('问题商户信息列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>商户编号：</label>
                            <input type="text" name="merno"/>
                        </li>
                        <li>
                            <label>商户名称：</label>
                            <input type="text" name="mer_name"/>
                        </li>
                        <li>
                            <label>法人姓名：</label>
                            <input type="text" name="legal_name"/>
                        </li>
                        <li>
                            <label>归属类型：</label>
                            <select id="type"  name="type"  style="height: 25px;">
                                <option value="">请选择</option>
                                <option value="0">问题商户</option>
                                <option value="1">人工审核</option>
                            </select>
                        </li>
                        <li class="select-time">
                            <label>创建时间：</label>
                            <input type="text" name="startlocaldate" data-toggle="datepicker" placeholder="起始时间" readonly="readonly" class="time-input" size="15">
                            <span>--</span>
                            <input type="text" name="endlocaldate" data-toggle="datepicker" placeholder="结束时间" readonly="readonly" class="time-input" size="15">
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success single" onclick="lookImg()">
                <i class="fa fa-search"></i> 查看图片
            </a>
            <a class="btn btn-success single" onclick="completeMerInfo()">
                <i class="fa fa-search"></i> 查看完整信息
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('merchantInfo:merchantInfo:edit')}]];
    var removeFlag = [[${@permission.hasPermi('merchantInfo:merchantInfo:remove')}]];
    var prefix = ctx + "merchantInfo/merchantInfo";
    var merType = [[${@dict.getType('mer_type')}]];
    var merStatus = [[${@dict.getType('mer_status')}]];
    $(function () {
        var options = {
            url: prefix + "/problemList",
            createUrl: prefix + "/lookImgProblem/{merNo}",
            updateUrl: prefix + "/edit/{id}",
            runOrBack: prefix + "updateProblemStatus/{merno}/{status}/{type}/{mer_status}",
            exportUrl: prefix + "/export",
            modalName: "商户信息",
            clickToSelect: true,
            columns: [{
                checkbox: true
                },
                {
                    field: 'MERNO',
                    title: '商户编号',
                },
                {
                    field: 'MER_NAME',
                    title: '商户名称'
                },
                {
                    field: 'LEGAL_NAME',
                    title: '法人姓名'
                },
                {
                    field: 'SHOW_LINKPHONE',
                    title: '手机号'
                },
                {
                    field: 'CREATE_TIME',
                    title: '创建时间'
                },
                {
                    field: 'UPDATE_TIME',
                    title: '修改时间'
                },
                {
                    field: 'PICTURE_TYPE',
                    title: '问题类型',
                    formatter: function (value, row, index) {
                        if (value == '1') {
                            return "身份证正面";
                        } else if (value == '2') {
                            return "身份证反面";
                        } else if (value == '3') {
                            return "银行卡正面";
                        } else {
                            return "多张同时存在问题";
                        }
                    }
                },
                {
                    field: 'TYPE',
                    title: '归属类型',
                    formatter: function (value, row, index) {
                        if (value == '0') {
                            return "问题商户";
                        } else if (value == '1') {
                            return "人工审核";
                        } else {
                            return "暂无";
                        }
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success" href="javascript:void(0)" onclick="runOrBack(\''+row.MERNO+'\',\''+row.TYPE+'\')"><i class="fa fa-plus"></i>通过</a> ');
                        actions.push('<a class="btn btn-success" href="javascript:void(0)" onclick="repulseMerInfo(\''+row.MERNO+'\',\''+row.TYPE+'\')"><i class="fa fa-plus"></i>打回</a> ');
                        return actions.join('');
                    }
                }
            ]
        };
        $.table.init(options);
    });

    /**
     *查看商户
     */
    function lookImg() {
        var merNo = $.table.selectColumns("MERNO")
        if ($.common.isEmpty(merNo)) {
            $.modal.alertWarning("请至少选择一条记录");
            return;
        }
        //如果是移动端，就使用自适应大小弹窗
        var width=1000;
        var height=$(window).height() - 50;
        if ($.common.isMobile()) {
            width = 'auto';
            height = 'auto';
        }
        var url=prefix + '/lookImgProblem/' + merNo;
        var btn = ['关闭'];
        var options = {
            title: '查看图片',
            width: width,
            height: height,
            url: url,
            btn: btn,
            yes:function(index){
                layer.close(index);
            }
        };
        $.modal.openOptions(options);
    }

    /**
     *查看完整信息
     */
    function completeMerInfo() {
        var merNo = $.table.selectColumns("MERNO")
        if ($.common.isEmpty(merNo)) {
            $.modal.alertWarning("请至少选择一条记录");
            return;
        }
        //如果是移动端，就使用自适应大小弹窗
        var width=1000;
        var height=$(window).height() - 50;
        if ($.common.isMobile()) {
            width = 'auto';
            height = 'auto';
        }
        var url=prefix + '/findPhone?merNo=' + merNo;
        var btn = ['关闭'];
        var options = {
            title: '查看完整信息',
            width: width,
            height: height,
            url: url,
            btn: btn,
            yes:function(index){
                layer.close(index);
            }
        };
        $.modal.openOptions(options);
    }

    function runOrBack(merno,type){
        table.set();
        $.modal.confirm("确定通过该条信息吗？", function() {
            var url = prefix + "/updateProblemStatus/"+merno+"/1/"+type+"/0";
            if(table.options.type == table_type.bootstrapTreeTable) {
                $.operate.get(url);
            } else {
                var data = { "merno": merno ,"status": 1 ,"type": type ,"mer_status": 0 };
                $.operate.submit(url, "post", "json", data);
            }
        });
    }

        function repulseMerInfo(id,type) {
        $.modal.open("打回", prefix + "/repulseMerInfo/"+id+"/"+type,1200,650);
    }


</script>
</body>
</html>